﻿USE [EyeOpen.Foo]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[City](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_City] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT [dbo].[City] ([Id], [Name]) VALUES (N'01653414-adc7-4164-a23b-2b4e151e47cd', N'Milano')
INSERT [dbo].[City] ([Id], [Name]) VALUES (N'86d1767b-6650-411c-92ed-dbc8015f7304', N'Verona')
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Town](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[CityId] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Town] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT [dbo].[Town] ([Id], [Name], [CityId]) VALUES (N'a476f413-83ad-44e6-90f6-3a2feee25a38', N'Milano', N'01653414-adc7-4164-a23b-2b4e151e47cd')
INSERT [dbo].[Town] ([Id], [Name], [CityId]) VALUES (N'f4595660-8bf8-4209-b3ae-a6be67714127', N'Verona', N'86d1767b-6650-411c-92ed-dbc8015f7304')
INSERT [dbo].[Town] ([Id], [Name], [CityId]) VALUES (N'14fe3500-d230-4e6f-959a-b0cbb22d2aac', N'Agrate', N'01653414-adc7-4164-a23b-2b4e151e47cd')
INSERT [dbo].[Town] ([Id], [Name], [CityId]) VALUES (N'35800cc5-36da-4fc7-89c1-cf17be5047b2', N'Peschiera', N'01653414-adc7-4164-a23b-2b4e151e47cd')
INSERT [dbo].[Town] ([Id], [Name], [CityId]) VALUES (N'ef2d499f-1542-406a-9c30-fdcf1a004f00', N'San Giovanni', N'86d1767b-6650-411c-92ed-dbc8015f7304')
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Customer](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[TownId] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT [dbo].[Customer] ([Id], [Name], [TownId]) VALUES (N'a94abfdf-4c8b-4404-a34e-6738627e36e9', N'Steve', N'f4595660-8bf8-4209-b3ae-a6be67714127')
INSERT [dbo].[Customer] ([Id], [Name], [TownId]) VALUES (N'76ff8604-4f79-4b39-a6b5-882f2084adeb', N'Bill', N'35800cc5-36da-4fc7-89c1-cf17be5047b2')
ALTER TABLE [dbo].[Customer]  WITH CHECK ADD  CONSTRAINT [FK_Customer_Town] FOREIGN KEY([TownId])
REFERENCES [dbo].[Town] ([Id])
GO
ALTER TABLE [dbo].[Customer] CHECK CONSTRAINT [FK_Customer_Town]
GO
ALTER TABLE [dbo].[Town]  WITH CHECK ADD  CONSTRAINT [FK_Town_City] FOREIGN KEY([CityId])
REFERENCES [dbo].[City] ([Id])
GO
ALTER TABLE [dbo].[Town] CHECK CONSTRAINT [FK_Town_City]
GO